<?php
require_once('application/business/UnitAvailability.php');
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class test_UnitAvailability extends CodeIgniterUnitTestCase {
    
    private $reservations;
    
    public function setUp() {
            $this->reservations = array(
                array(
                    'start' => strtotime('20.08.2013'),
                    'end' => strtotime('23.08.2013'),
                    'unit_number' => 1
                ), array(
                    'start' => strtotime('25.08.2013'),
                    'end' => strtotime('28.08.2013'),
                    'unit_number' => 2
                ), array(
                    'start' => strtotime('21.08.2013'),
                    'end' => strtotime('24.08.2013'),
                    'unit_number' => 3
                )
            );
       }   
    public function test_is_unit_free() {
        $unit_availability = new UnitAvailability();
        $unit_availability->setReservations($this->reservations);
        $unit_availability->setNumber_of_units(7);
        $result = $unit_availability->is_unit_free(strtotime('20.08.2013'), strtotime('23.08.2013'), 2);
        $this->assertEqual($result, 'Unit is free for reservation');
          
    }
    public function test_is_unit_not_free() {
        $unit_availability = new UnitAvailability();
        $unit_availability->setReservations($this->reservations);
        $unit_availability->setNumber_of_units(7);
        $result = $unit_availability->is_unit_free(strtotime('20.08.2013'), strtotime('23.08.2013'), 1);
        $this->assertEqual($result, 'Unit is reserved for that period'); 
    } 
}

